﻿using System;
using System.Xml;
using RAP.Framework.Libary.DomTemplateBuilder.Interface;
using RAP.Framework.Libary.DomTemplateBuilder.Attributes;
using RAP.Framework.Libary.DomTemplateBuilder.Handler;

namespace RAP.Framework.Libary.DomTemplateBuilder.Element
{
	/// <summary>
	/// 默认值节点基类
	/// </summary>
	[TagHandler( typeof( DefaultValueHandler ) )]
	public class DefaultValue : ValueTyped
    {
		public override void Initialize ( XmlNode node )
		{
			this.ParseXMLAttributes ( node );
			IDefaultValueElement parent = this.Parent as IDefaultValueElement;
			if ( parent == null )
			{
				return;
			}
			if ( parent.DefaultValue != null )
			{
				throw new Exception ( "节点只能包含一个DefaultValue节点！" );
			}
			parent.DefaultValue = this;
		}
	}
}
